#include "main/utils.h"
using namespace std;

class MovingAverage {
  public:
    MovingAverage(int size) : size_(size) {};
    double next(int num) {
      deque.push_back(num);
      sum += num;
      if (deque.size() > size_) {
        int front_num = deque.front();
        deque.pop_front();
        sum -= front_num;
      }
      return sum / deque.size();
    }
  private:
    deque<int> deque;
    double sum;
    int size_;
};

int main() {
  MovingAverage ma(3);
  cout << ma.next(1) << " 1 " << endl;
  cout << ma.next(2) << " 1.5 " << endl;
  cout << ma.next(3) << " 2 " << endl;
  cout << ma.next(4) << " 3 " << endl;
  cout << ma.next(5) << " 4 " << endl;
  cout << ma.next(6) << " 5 " << endl;

  return 0;
}
